package org.makcro.sms.services.chat.web.client.widgets.bulk;

import java.util.ArrayList;
import java.util.List;

import org.makcro.sms.services.chat.web.client.widgets.EntityListBase;
import org.makcro.sms.services.chat.web.shared.dto.BulkMessageDto;

import com.extjs.gxt.ui.client.data.PagingLoadResult;
import com.extjs.gxt.ui.client.data.PagingLoader;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.google.gwt.i18n.client.DateTimeFormat;

/**
 * Panel for bulk search compoentns
 * 
 * @author makcro
 * 
 */
public class BulkSearchPanel extends EntityListBase<BulkMessageDto> {

	public BulkSearchPanel(PagingLoader<PagingLoadResult<BulkMessageDto>> pagingLoader) {
		super( pagingLoader );
	}

	@Override
	public ColumnModel getColumnModel() {
		if (this.columnModel == null) {
			// create columns
			List<ColumnConfig> columns = new ArrayList<ColumnConfig>();
			ColumnConfig idColumn = new ColumnConfig( "id", "#", 30 );
			ColumnConfig textColumn = new ColumnConfig( "messageText", "Tekst poruke", 200 );
			ColumnConfig receiverColumn = new ColumnConfig( "receiver", "Primalac", 100 );
			ColumnConfig deliveryStatusColumn = new ColumnConfig( "delivered", "Isporucena", 100 );
			ColumnConfig sendingTimeColumn = new ColumnConfig( "sendingTime", "Vreme slanja", 100 );
			sendingTimeColumn.setDateTimeFormat( DateTimeFormat.getFormat( "dd/MM/yyyy 'u' HH:mm" ) );
			// add columns in right order
			columns.add( idColumn );
			columns.add( receiverColumn );
			columns.add( sendingTimeColumn );
			columns.add( deliveryStatusColumn );
			columns.add( textColumn );

			this.columnModel = new ColumnModel( columns );
		}
		return columnModel;
	}

}
